package org.prism.reflection.optional;

import org.junit.Test;
import org.prism.reflection.bean.Apple;

import java.util.Optional;

public class OptionalTest {
    @Test
    public void test01(){
        String s1 = "王朋龙";
        Apple apple = new Apple();
        Optional<Apple> apple1 = Optional.of(apple);
        System.out.println("apple1 = " + apple1);
    }
    @Test
    public void test02(){
        Apple apple = new Apple();
//        apple = null;
        Optional<Apple> optionalApple = Optional.ofNullable(apple);
        Apple iphoneSE = optionalApple.orElse(new Apple(1001, "iphoneSE", 4599.0));
        System.out.println("iphoneSE = " + iphoneSE);
    }
}
